/*
 * @(#)XfslEvaluation.java        1.0 2009/01/01
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package xfuzzy.xfsl.model;

/**
 * Clase que almacena la evaluacion de un sistema
 * 
 * @author Francisco Jose Moreno Velo
 *
 */
public class XfslEvaluation implements Cloneable {

	//----------------------------------------------------------------------------//
	//                            MIEMBROS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Valor de la funcion de error
	 */
	public double error;
	
	/**
	 * Valor del RMSE
	 */
	public double rmse;
	
	/**
	 * Valor del maximo error absoluto
	 */
	public double mxae;
	
	/**
	 * Variacion del error respecto a la iteracion anterior
	 */
	public double var;

	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor por defecto
	 */
	public XfslEvaluation() {
		this.error = 1;
		this.rmse = 1;
		this.mxae = 1;
		this.var = 1;
	}

	/**
	 * Constructor sin variacion del error
	 */
	public XfslEvaluation(double error, double mse, double mxae, int num) {
		this.error = error/num;
		this.rmse = Math.sqrt(mse/num);
		this.mxae = mxae;
		this.var = 0;
	}

	/**
	 * Constructor con variacion del error
	 */
	public XfslEvaluation(double error, double mse, double mxae, double lasterror,
			int num) {
		this.error = error/num;
		this.rmse = Math.sqrt(mse/num);
		this.mxae = mxae;
		this.var = (lasterror - this.error)/lasterror;
	}

	/**
	 * Constructor para error de clasificaci�n
	 */
	public XfslEvaluation(double error, double misscr, double misscn) {
		this.error = error;
		this.rmse = misscr;
		this.mxae = misscn;
		this.var = 0;
	}

	/**
	 * Constructor para error de clasificaci�n con variaci�n
	 */
	public XfslEvaluation(double error, double misscr, double misscn, double le) {
		this.error = error;
		this.rmse = misscr;
		this.mxae = misscn;
		this.var = (le-error)/le;
	}

	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Descripci�n para el fichero de log
	 */
	public String toString() {
		return ""+this.error+" "+this.rmse+" "+this.mxae+" "+this.var;
	}

	/**
	 * Duplicado del objeto
	 */
	public Object clone() {
		try { return super.clone(); }
		catch (CloneNotSupportedException e) { return null; }
	}
}
